const mongoose = require('mongoose');
const FlashSaleActivityModel = require('./FlashSaleActivity');

mongoose.connect(
  'mongodb+srv://2334231668:xin123666@cluster0.13va5ah.mongodb.net/2409B',
  { useNewUrlParser: true, useUnifiedTopology: true }
);

const testData = [
  { name: '春季秒杀活动', time: '2021-03-02 ~ 2021-03-12', productCount: 10, status: '进行中', online: '上线' },
  { name: '夏季秒杀活动', time: '2021-06-01 ~ 2021-06-10', productCount: 8, status: '未开始', online: '下线' },
  { name: '双11大促', time: '2021-11-01 ~ 2021-11-11', productCount: 20, status: '已结束', online: '上线' },
  { name: '618大促', time: '2021-06-18 ~ 2021-06-20', productCount: 15, status: '进行中', online: '上线' },
  { name: '年货节', time: '2021-01-10 ~ 2021-01-20', productCount: 12, status: '已结束', online: '下线' }
];

async function insertData() {
  await FlashSaleActivityModel.deleteMany({}); // 清空旧数据
  await FlashSaleActivityModel.insertMany(testData);
  console.log('测试数据插入成功');
  mongoose.disconnect();
}

insertData(); 